package com.ltxtiyu.video;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.concurrent.CountDownLatch;

@SpringBootApplication
@EnableCaching  // 开启缓存
public class LtxTaskApplication implements CommandLineRunner, DisposableBean {

    private final Logger log = LoggerFactory.getLogger(LtxTaskApplication.class);

    private final static CountDownLatch latch = new CountDownLatch(1);
    private static ConfigurableApplicationContext context;

    public static void main(String[] args) {
        SpringApplication.run(LtxTaskApplication.class, args);
    }

    @Override
    public void destroy() throws Exception {
        latch.countDown();
        context.close();
        log.info(">>>>>>>>>>>>ltx-task关闭");
    }

    @Override
    public void run(String... args) throws Exception {
        log.info(">>>>>>>>>>>>ltx-task启动");
    }
}
